Grokking Database Fundamentals for Tech Interviews
Rate this course
Ask Author
Contribute
Back to course home

0% completed

Vote For New Content
Introduction to Database Systems
Course Overview
Overview of Databases
Core Components of Database
Database Architectures
Relational Vs. Non-relational Databases
Data Storage in DBMS
Data Storage Fundamentals
File Organization in DBMS
Data Compression and Encoding
Quiz
Indexing in DBMS
Introduction to Database Indexes
Single Level Indexing
Tree-Based Indexing Techniques
Hash-Based Indexing
Bloom Filters
Quiz
Transaction Management
Understanding the Transaction
Atomicity
Consistency
Isolation
Durability
Quiz
Concurrency Control
Understanding the Concurrency Control
Optimistic vs. Pessimistic Concurrency Control
Lock-Based Concurrency Control
Timestamp-Based Concurrency Control
Multiversion Concurrency Control (MVCC)
Quiz
Distributed Databases, Data Partitioning & Sharding
Fundamentals of Distributed Databases
Partitioning in Databases
Partitioning Types
Sharding in Databases
Distributed Query Processing
Quiz
Data Replication and Consistency Models
Replication in Databases
Replication Topologies
Understanding the Consistency Models in Databases
The CAP Theorem and Its Implications
Quiz
Consenus and Leader Election
Understanding the Consensus
Consensus algorithms
Leader Election Strategies
Quiz
Recovery and Fault Tolerance in Distributed Databases
Understanding the Fault Tolerance
Logging Mechanisms in Databases
Checkpointing and Recovery Basics
Coordinated Recovery in Distributed Systems
High Availability Through Replication and Failover
Ensuring Data Resilience: Redundancy, Mirroring, and Recovery
Quiz
Introduction to NoSQL
Key-Value Stores
Document-Oriented Databases
Column-Family and Wide-Column Stores
Graph Databases
Quiz
Quora System Design & Database Design
TikTok System Design & Database Design
Airbnb System Design & Database Design
Snapchat System Design & Database Design
Ensuring Data Resilience: Redundancy, Mirroring, and Recovery

Ensuring data availability and integrity is critical for any distributed system. Failures, whether due to hardware, software, or environmental factors, are inevitable. This lesson explores how data redundancy, mirroring, and backup/restoration strategies protect systems from media failures and ensure smooth recovery.

1. Data Redundancy

Data redundancy involves storing multiple copies of data across different locations to ensure availability and protect against data loss.

Techniques for Data Redundancy

  1. Replication:

    • Copies of data are maintained on multiple nodes.
    • Used in distributed systems for high availability and fault tolerance.
  2. RAID (Redundant Array of Independent Disks):

    • Combines multiple physical disks into a single logical unit.
    • Levels like RAID 1, RAID 5, and RAID 6 offer varying degrees of redundancy and performance.
  3. Erasure Coding:

    • Data is split into fragments and encoded with redundancy.
    • Only a subset of fragments is needed to reconstruct the data, reducing storage overhead compared to full replication.

2. Mirroring

Mirroring is a specific form of redundancy where an exact copy of data is maintained in real-time.

How Mirroring Works

  • Every write to the primary disk or node is instantly duplicated on the mirror.
  • If the primary fails, the mirror takes over seamlessly.

Advantages:

  • Immediate failover ensures minimal downtime.
  • High data integrity since the mirror is always up-to-date.

Disadvantages:

  • Doubles storage costs due to the need for a full copy.
  • May increase write latency for real-time updates.

Example:

  • A banking system mirrors its transaction database between two data centers to ensure no data is lost during failures.

3. Media Failure Recovery

Media failures occur when storage devices (e.g., hard drives or SSDs) malfunction. Recovery from such failures requires proactive and reactive strategies.

Types of Media Failures:

  1. Physical Damage: Disk corruption, broken hardware.
  2. Logical Corruption: Software bugs or malware causing data errors.

Strategies for Media Failure Recovery

  1. Hot Swapping: Replace failed drives in RAID arrays without shutting down the system.
  2. Regular Health Monitoring: Tools like SMART (Self-Monitoring, Analysis, and Reporting Technology) to detect potential drive failures early.
  3. Data Scrubbing: Periodically check and repair corrupted data blocks.
  4. Data Replication: Store multiple copies of data across different nodes or regions to ensure quick recovery from failures.

4. Backup and Restoration

Backup is the process of creating additional copies of data for protection against catastrophic failures. Restoration involves recovering from backups after a failure.

Types of Backups

  1. Full Backup:

    • A complete copy of all data.
    • Pros: Simplifies restoration.
    • Cons: Time-consuming and storage-intensive.
  2. Incremental Backup:

    • Captures only the changes made since the last backup.
    • Pros: Saves storage and time.
    • Cons: Restoration may require multiple backups.
  3. Differential Backup:

    • Captures changes since the last full backup.
    • Pros: Faster restoration compared to incremental backups.
    • Cons: Requires more storage than incremental backups.

Best Practices for Backup and Restoration

  1. Backup Frequency: Schedule backups based on system criticality (e.g., daily for business-critical systems).

  2. Offsite Storage: Store backups in a remote location or cloud to protect against regional disasters.

  3. Testing Restorations: Regularly verify that backups can be restored to ensure they are usable.

  4. Versioning: Keep multiple backup versions to recover from data corruption or ransomware attacks.

Example Scenario

A hospital’s patient records are backed up daily using:

  • Full backup on weekends for complete redundancy.
  • Incremental backups on weekdays to save storage.
  • The backups are stored both locally and in the cloud to handle regional failures.
High Availability Through Replication and Failover
Quiz
Mark as Completed

On this page

  1. Data Redundancy

Techniques for Data Redundancy

  1. Mirroring

How Mirroring Works

Advantages:

Disadvantages:

Example:

  1. Media Failure Recovery

Types of Media Failures:

Strategies for Media Failure Recovery

  1. Backup and Restoration

Types of Backups

Best Practices for Backup and Restoration

Example Scenario